using SQLServices.Runners.Events;
using SQLServices.TransMgr;

namespace SQLServices.Runners
{
	/// <summary>
	/// The main role of the Runner is to execute the scripts against the
	/// SQL Server database.
	/// There are two ways to start the execution of the scripts: In synch or async.
	/// The Runner defines events so it can inform of the progress back to the caller or other listeners
	/// The CancelExecution method is used to interrupt the execution of the scripts if the execution is 
	/// done in a different thread.
	/// </summary>
	public interface IRunner
	{
        /// <summary>
        /// Use by the runner to pass a message back to the caller during the execution
        /// </summary>
		event ProgressMsgCreatedEventHandler ProgressMsgCreated;

        /// <summary>
        /// Informs that an exception was thrown during the execution of a script
        /// </summary>
		event ScriptExecErrorEventHandler ScriptExecError;

        /// <summary>
        /// Informs that a script has been executed
        /// </summary>
		event ScriptExecutedEventHandler ScriptExecuted;

        /// <summary>
        /// The runner triggers this event when all the scripts have been executed
        /// </summary>
		event ExecutionFinishedEventHandler ExecutionFinished;

	    ConnectionMgrType ConnectionMgrType
	    {
	        get;
	        set;
	    }

	    /// <summary>
        /// Starts executing the scripts indicating that the execution should be done
        /// in asynchronous mode
        /// </summary>
		void RunScriptsAsync();

        /// <summary>
        /// Starts executing the scripts
        /// </summary>
		void RunScripts();

        /// <summary>
        /// Use to inform the Runner that the execution of the scripts should be stopped
        /// </summary>
		void CancelExecution();
	}
}